package com.lw.unsafe;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author LW
 * @2020/8/19 22:45
 */
//java.util.ConcurrentModificationException
public class MapTest {

    public static void main(String[] args) {
        //map这样用的么？   不用，工作中不用HashMap
        //默认等价与什么？   初始容量initialCapacity=16     加载因子loadFactor=0.75
//        Map<String, String> map = new HashMap<>();
//            Map<String, String> map = Collections.synchronizedMap(new HashMap<>());
            Map<String, String> map = new ConcurrentHashMap<>();
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                map.put(Thread.currentThread().getName(), UUID.randomUUID().toString().substring(0,5));
                System.out.println(map);
            }).start();
        }


    }
}
